<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>${fns:getConfig('productName')}</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script src="${ctx}/js/echarts.js"></script>
<script src="${ctx}/scripts/tj/echart_init.js"></script>
<script>
 var year;
	$(function(){
		//初始加载某一年的统计数据
		$("a[name='year']").each(function(){
			if($(this).attr("class").indexOf("btn-danger")>=0){
				year = $(this).attr('id')
				countJson(year);
			}
		});
		//为每个年份绑定click事件
		$("a[name='year']").click(function(){
			$("a[name='year']").each(function(){
				$(this).removeClass('btn-danger');
			});
			$(this).addClass('btn-danger');
			year = $(this).attr('id')
			countJson(year);
		});
		
	})
	
	function countJson(projectYear){
		var url = "${ctx}/lifeProject/attCountJson.do?year="+projectYear;
		$.ajax({
			type:'POST',
			url:url,
			async:false,
			dataType:'json',
			success:function(data){
				$('#project table').remove();
				echartsData =  ECharts.ChartDataFormate.GetYAndGroupData(data); //解析数据 便于echarts显示
				category = echartsData.category;
				xAxis = echartsData.xAxis;
				dataJson = echartsData.result;
				var myechart = echarts.init(document.getElementById('zx-urban'));
				var option;
				myechart.clear(); 
				option = ECharts.ChartOptionTemplates.Lines(data,year+"日常监管附件汇总表",'文件数');  
				myechart.setOption(option);
				if(category.length !=0){
					dataTableView(category,xAxis,dataJson,'project','业务模块');
					$("#downFile").attr('href','${ctx}/lifeProject/attExport.do?year='+projectYear);
				} else {
					$('#downFile').css('display','none');
				}
			}
		})
	}
	

function down(){
	var url = "${ctx}/lifeProject/export.do?year="+year;
	console.log(url);
	$.ajax({
		type:'POST',
		url:url,
		async:false,
		dataType:'json',
		success:function(data){
			
		}
	})
}
</script>
</head>
<body>
	<div style="margin-top: 10px;float: left;margin-left:20px;" id="tec_field">
         <label >数据年份:</label>
    	<c:forEach items="${list}" var='year' varStatus="status">
    		<a  name="year" id="${year}" class="btn btn-primary btn-lg <c:if test="${status.index==0}">btn-danger</c:if>" role="button" style="margin-bottom: 10px;" >
				${year}年
   			</a>
    	</c:forEach>
    	</div>
    	<hr style="clear:both">
    	<div  style="padding-bottom:10px;width:80%;margin:auto" id="project" >
    	<div id="zx-urban" style="height: 350px;width:100%;float:left;"></div>
    	<div style="float:left;margin:5px;">
    		<a href ="" id="downFile" class="btn btn-primary" role="button">下载</a>
    	</div>
    	
    	</div>
    	
</body>
</html>